home *** CD-ROM | disk | FTP | other *** search
-
- #include "main.h"
-
- //kontruktor
- //-----------------------------------------------------------------
- FIREBALL::FIREBALL()
- {
-
- //inicializacia segmentov
- for (int i=0;i<FireBall_Max;i++)
- {
- Segment[i].Pos = Get3D(0.0f,0.0f,0.0f);
- Segment[i].Active = false;
- Segment[i].Time = 0.0f;
- }
-
- //inicializacia vlastnosti
- SRCColor = GetColor(1.0f,1.0f,1.0f,1.0f);
- DSTColor = GetColor(0.0f,0.0f,0.0f,0.0f);
- SRCRot = Get3D(0.0f,0.0f,0.0f);
- DSTRot = Get3D(0.0f,0.0f,0.0f);
- RandRotation = false;
- SRCScale = Get3D(1.0f,1.0f,1.0f);
- DSTScale = Get3D(5.0f,5.0f,5.0f);
- Time = 1000.0f;
-
- }
-
- //inicializacia - load modelu
- //-----------------------------------------------------------------
- void FIREBALL::Initialize(char *ModelFileName,char *TextureFileName,COLOR TColor)
- {
- Model.Lighting = false;
- Model.SmoothShading = false;
- Model.Normals = false;
- Model.Color = GetColor(1,0,0,0);
- Model.InitializeAse(1,ModelFileName);
- Model.LoadAse(0,ModelFileName);
- Model.LoadTexture(TextureFileName,TColor);
- Model.Lighting = true;
-
- }
-
- //render & process
- //-----------------------------------------------------------------
- void FIREBALL::Refresh()
- {
- float Int;
-
- for (int i=0;i<FireBall_Max;i++)
- {
- if (Segment[i].Active == false)
- continue;
-
- //casovac
- Segment[i].Time += PowerTime(1.0f);
- if (Segment[i].Time > Time)
- {
- Segment[i].Active = false;
- continue;
- }
-
- //interpolant
- Int = Segment[i].Time/Time;
- if (Int > 1.0f) Int = 1.0f;
- if (Int < 0.0f) Int = 0.0f;
-
- //render
- Model.Sca.X = SRCScale.X + ((DSTScale.X-SRCScale.X)*Int);
- Model.Sca.Y = SRCScale.Y + ((DSTScale.Y-SRCScale.Y)*Int);
- Model.Sca.Z = SRCScale.Z + ((DSTScale.Z-SRCScale.Z)*Int);
-
- if (RandRotation)
- {
- Model.Rot = Segment[i].Rot;
- }
- else
- {
- Model.Rot.X = SRCRot.X + ((DSTRot.X-SRCRot.X)*Int);
- Model.Rot.Y = SRCRot.Y + ((DSTRot.Y-SRCRot.Y)*Int);
- Model.Rot.Z = SRCRot.Z + ((DSTRot.Z-SRCRot.Z)*Int);
- }
-
- // Model.Color.A = SRCColor.A + ((DSTColor.A-SRCColor.A)*Int);
- // Model.Color.R = SRCColor.R + ((DSTColor.R-SRCColor.R)*Int);
- // Model.Color.G = SRCColor.G + ((DSTColor.G-SRCColor.G)*Int);
- // Model.Color.B = SRCColor.B + ((DSTColor.B-SRCColor.B)*Int);
-
- Model.SetMaterial(GetMaterial(GetColor(0,0,0,0),
- GetColor(0,0,0,0),
- GetColor(0,0,0,0),
- GetColor(SRCColor.A + ((DSTColor.A-SRCColor.A)*Int),
- SRCColor.R + ((DSTColor.R-SRCColor.R)*Int),
- SRCColor.G + ((DSTColor.G-SRCColor.G)*Int),
- SRCColor.B + ((DSTColor.B-SRCColor.B)*Int)),
- 0.0f));
- Model.Pos = Segment[i].Pos;
-
- Engine.SetZwrite(false);
- Model.Render();
- Engine.SetZwrite(true);
-
- }
-
- }
-
- //vypustenie segmentu
- //-----------------------------------------------------------------
- void FIREBALL::Spawn(VECTOR3D Pos)
- {
- for (int i=0;i<FireBall_Max;i++)
- {
- if (Segment[i].Active == true)
- continue;
-
- Segment[i].Active = true;
- Segment[i].Pos = Pos;
- Segment[i].Time = 0.0f;
-
- if (RandRotation)
- {
- Segment[i].Rot.X = RandomMinMax(-3.14f,3.14f);
- Segment[i].Rot.Y = RandomMinMax(-3.14f,3.14f);
- Segment[i].Rot.Z = RandomMinMax(-3.14f,3.14f);
- }
-
- break;
- }
-
- }